<template>
  <ContentWrap>
    <template #header>
      <div class="card-header">
        <span class="card-title">损坏文物修复分析</span>
      </div>
    </template>
    <div class="card-content">
      <div class="chart" ref="chartRef"></div>
    </div>
  </ContentWrap>
</template>

<script lang="ts" setup>
import * as echarts from 'echarts'

const chartRef = shallowRef()
const myChart = shallowRef()
const initChart = () => {
  myChart.value = echarts.init(chartRef.value)
  const option = {
    tooltip: {
      trigger: 'axis',
      axisPointer: {
        type: 'shadow'
      }
    },
    legend: {},
    grid: {
      left: '3%',
      right: '4%',
      bottom: '3%',
      containLabel: true
    },
    color: ['#F5EDD9', '#D8C9A7', '#AB9266'],
    yAxis: [
      {
        type: 'category',
        data: ['青铜器', '瓷器', '陶器', '书画', '绘画', '玉石器', '石刻']
      }
    ],
    xAxis: {
      type: 'value',
    },
    series: [
      {
        name: '短期',
        type: 'bar',
        stack: 'ad',
        emphasis: {
          focus: 'series'
        },
        data: [320, 332, 301, 334, 390, 330, 320]
      },
      {
        name: '中期',
        type: 'bar',
        stack: 'ad',
        emphasis: {
          focus: 'series'
        },
        data: [120, 132, 101, 134, 90, 230, 210]
      },
      {
        name: '长期',
        type: 'bar',
        stack: 'ad',
        emphasis: {
          focus: 'series'
        },
        data: [120, 132, 101, 134, 90, 230, 210]
      },
    ]
  }
  myChart.value.setOption(option)
}
onMounted(() => {
  initChart() 
})
</script>

<style lang="scss" scoped>
.card-header {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  .card-title {
    font-weight: bold;
    line-height: 32px;
  }
  .more {
    font-size: 14px;
  }
  :deep(.el-tabs__header) {
    margin: 0;
  }
}
.card-content {
  padding: 0 10px;
}
.chart {
  width: 100%;
  height: 220px;
}
:deep(.el-card__header) {
  padding: 10px;
}
</style>
